package com.leo.algorithm.排序;

/**
 * 冒泡排序
 */
public class BubblingSort {

    public static void main(String[] args) {
        int arr[]={2,4,1,6,5,8,9,10,3,7};
        int[] bub = bub(arr);
        for (int i = 0; i <bub.length ; i++) {
            System.out.println(bub[i]);
        }

    }

    private static int[] bub(int []arr){

        for (int i =0; i < arr.length ; i++) {
            for (int j = i+1; j <= arr.length-1 ; j++) {
                if(arr[i]>arr[j]){
                    int temp =arr[i];
                    arr[i]=arr[j];
                    arr[j]=temp;
                }
            }
        }
        return  arr;
    }
}
